The WebObjects Adaptor enables WebObjects Framework or a WebObjects application to be HTTP Server independent in the same way that an EOF Adaptor provides database independence.
The WebObjects Adaptor exists as an executable file with a filename of WebObjects under the WebServer/cgi-bin directory. Here are typical WebObjects Adaptor file names
Platform Filename and extension NEXTSTEP WebObjects Solaris WebObjects Windows NT WebObjectsTo install the Adaptor, move it from the WebServer/cgi-bin directory to your Web server's cgi-bin directory, if needed.
The Adaptor receives information from the Server according to the CGI protocol, using environment variables and a character string (stdin). The Adaptor trades HTTP formatted information with the WebObjects application, passing HTTP responses containing HTML pages back to the Server.
The Adaptor may start up a WebObjects application if needed.
Structural Model The WebObjects Adaptor consists of two parts, a Web server-side part and a WebObjects application part.
The application part consists of special classes that are part of every WebObjects application.
The server-side part is a stand-alone CGI program. Note, you should not attempt to start the CGI program, WebObjects, manually. The Adaptor and Server must be located on the same computer.
The WebObjects application may reside on the same computer or on a remote computer.
When a WebObjects application is requested with a URL such as:
http://<myServerHost>/cgi-bin/WebObjects/Examples/HelloWorldThe WebObjects Adaptor can handle it in three different ways :
A. Autostart a WebObjects application and then contact it.
B. Contact an WebObjects application started manually from a terminal window.
C. Load balance requests between many WebObjects application started manually.
If the WebObjects application is not started yet, the adaptor will autostart it and then connect to it.
There is nothing the user should do to ask for this behavior, it occurs automatically after all other attempts to contact the application have failed. Please see D for the detailed order in which the attempts are made.
Autostarting uses the DefaultApp executable (located in /NextLibrary/WebObjects/Executables) with the following arguments :
DefaultApp -dTheExamples/HelloWorld
There are two ways of doing this from a terminal window. Both use the DefaultApp executable that's in /NextLibrary/WebObjects/Executables.
Change directories to /NextLibrary/WebObjects/Executables and enter:
./DefaultApp Examples/HelloWorldThis will start a single instance of the WebObjects application HelloWorld located in your documentRoot/Examples/HelloWorld directory. This is the simplest way to start an application by hand, with the limitation that you can only have one application with this name running on the server host.
First, from a machine we'll call myHost, change directories to /NextLibrary/WebObjects/Executables and start the application in a terminal window by entering:
./DefaultApp -p 3000 -n 1 Examples/HelloWorldThis will start instance1 of HelloWorld on port 3000 of myHost
Second, go to your server machine <myServerHost> and create/edit a file WebObjects.conf in your server's cgi-bin directory. Type this line in the file :
Examples/HelloWorld:1@myHost 3000And save the file. This lets the WebObjects adaptor now that an application HelloWorld #1 is available on the machine myHost at port 3000 for serving requests.
Now try contacting with the same url as before your application :
http://<myServerHost>/cgi-bin/WebObjects/Examples/HelloWorldAll requests for Examples/HelloWorld will be forwarded on myHost to this WebObjects application.
You can as well force using one given application running on a host by typing in your browser :
http://<myServerHost>/cgi-bin/WebObjects/Examples/HelloWorld:1@myHostadvice: always pick ports greater than 1024 as ports under 1024 are reserved on UNIX platforms.
From <myHost>, start these applications in a terminal window by typing from the /NextLibrary/WebObjects/Executables :
./DefaultApp -p 3000 -n 1 Examples/HelloWorld (if it is not already running) ./DefaultApp -p 4000 -n 2 Examples/HelloWorldFrom <mySecondHost>, start these applications in a terminal window by typing from the /NextLibrary/WebObjects/Executables :
./DefaultApp -p 3000 -n 1 Examples/HelloWorld ./DefaultApp -p 4000 -n 1 CyberWindFrom <myServerHost>, if WebObjects was installed on it, start these applications in a terminal window by typing from the /NextLibrary/WebObjects/Executables:
./DefaultApp -p 5000 -n 33 Examples/HelloWorldNow on your server machine, edit the file WebObjects.conf in your server's cgi-bin directory. It should now be changed to look like this:
Examples/HelloWorld:1@<myHost> 3000 Examples/HelloWorld:2@<myHost> 4000 Examples/HelloWorld:1@<mySecondHost> 3000 CyberWind:1@<mySecondHost> 4000 Examples/HelloWorld:33@<myServerHost> 5000Now try contacting with the same url as before your application:
http://<myServerHost>/cgi-bin/WebObjects/Examples/HelloWorldThe adaptor will pick one of the 4 HelloWorld applications it knows about, and try to contact it. If the application it tried to contact is not available (because serving someone else), it will wait. If the application it tried to contact died or was just not started, it will fail.
If your application carries state for the client between requests, the generated HTML pages will contain the complete path to return to the exact application that served the given client in his previous request, with links such as :
http://<myServerHost>/cgi-bin/WebObjects/Examples/HelloWorld:33@<myServerHost>and no load-balancing will be performed as long as the session lasts. Otherwise, if there is no state carried on, your application will automatically return HTML pages with links like:
http://<myServerHost>/cgi-bin/WebObjects/Examples/HelloWorldso that the adaptor can perform load balancing on the following requests, and possibly end up contacting another application.
You can as well contact the application CyberWind, but as there is only one application, there won't be any load balancing performed and all requests for CyberWind will always go to this same application.
Of course, you can have both autostarted applications and load-balanced applications (started by hand) at all time, as long as they don't have the same names. When names conflicts, the load-balanced applications will be picked rather than any previously autostarted application.
tail -f /tmp/CGIMessenger.logThis will log any activity of the WebObjects adaptor, and you will be able to trace its behavior according to section D., and find out why you can not connect to the WebObjects application. Do not forget to remove the /tmp/logWebObjects file to stop the logs when you have successfully deployed your WebObjects application. Note for Windows NT users: In order to enable debugging you should create the logWebObjects file in the directory specified by the TEMP environment variable. You can use Notepad to view the resulting CGIMessenger.log file. Keep in mind that the file will is changed during each request so you may need to close and reopen it in order to monitor adaptor activity.
b. Some more details about the configuration file :
<application-directory>:<application-number>@<host-name> <application-port>